Page({
  data: {
    sliderList: [
      { text: 'A' },
      { text: 'B' },
      { text: 'C' },
      { text: 'D' },
    ],
    
    sliderConfig: [
      {
        width: 120,
        bgColor: '#43CD80',
        text: '同意'
      },
      {
        width: 120,
        bgColor: '#FF4040',
        text: '拒绝'
      },
    ],

    customCallback: {
      0: 'consent',
      1: 'reject'
    }
  },
  
  getKey(e) {
    let ed = e.detail;
    this.setData({
      key: ed.key
    });
  },

  sliderCallback(e){
    let _this = this, ed = e.detail;
    wx.showModal({
      title: '提示',
      content: '确认要删除吗？',
      success(res){
        if(res.confirm){
          wx.showToast({
            title: `key：${ed.key} | itemParams：${ed.params.text}`,
            icon: 'none'
          });
        }else{
          _this.setData({
            key: -1
          });
        }
      }
    })
  },

  customSliderCallback(e){
    let td = this.data, ed = e.detail;
    this[td.customCallback[ed.index]](ed);
  },

  consent(e){
    wx.showToast({
      title: '同意',
      icon: 'none'
    });
  },

  reject(e) {
    wx.showToast({
      title: '拒绝',
      icon: 'none'
    });
  }
});